package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizDidian;
import com.ruoyi.system.service.IBizDidianService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地点信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-29
 */
@Controller
@RequestMapping("/system/didian")
public class BizDidianController extends BaseController
{
    private String prefix = "system/didian";

    @Autowired
    private IBizDidianService bizDidianService;

    @RequiresPermissions("system:didian:view")
    @GetMapping()
    public String didian()
    {
        return prefix + "/didian";
    }

    /**
     * 查询地点信息列表
     */
    @RequiresPermissions("system:didian:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizDidian bizDidian)
    {
        startPage();
        List<BizDidian> list = bizDidianService.selectBizDidianList(bizDidian);
        return getDataTable(list);
    }

    /**
     * 导出地点信息列表
     */
    @RequiresPermissions("system:didian:export")
    @Log(title = "地点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizDidian bizDidian)
    {
        List<BizDidian> list = bizDidianService.selectBizDidianList(bizDidian);
        ExcelUtil<BizDidian> util = new ExcelUtil<BizDidian>(BizDidian.class);
        return util.exportExcel(list, "地点信息数据");
    }

    /**
     * 新增地点信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存地点信息
     */
    @RequiresPermissions("system:didian:add")
    @Log(title = "地点信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizDidian bizDidian)
    {
        return toAjax(bizDidianService.insertBizDidian(bizDidian));
    }

    /**
     * 修改地点信息
     */
    @RequiresPermissions("system:didian:edit")
    @GetMapping("/edit/{sn}")
    public String edit(@PathVariable("sn") Long sn, ModelMap mmap)
    {
        BizDidian bizDidian = bizDidianService.selectBizDidianBySn(sn);
        mmap.put("bizDidian", bizDidian);
        return prefix + "/edit";
    }

    /**
     * 修改保存地点信息
     */
    @RequiresPermissions("system:didian:edit")
    @Log(title = "地点信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizDidian bizDidian)
    {
        return toAjax(bizDidianService.updateBizDidian(bizDidian));
    }

    /**
     * 删除地点信息
     */
    @RequiresPermissions("system:didian:remove")
    @Log(title = "地点信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizDidianService.deleteBizDidianBySns(ids));
    }
}
